package com.zzf;

import org.junit.Test;

import java.util.Arrays;

public class interviewDemo {

    /**
     * ==和equals的区别
     */
    @Test
    public void test01() {
        String a = "123";
        String b = null;
        String c = "123";
        System.out.println(a.equals(c));
        /*if (b.equals(a)){
            System.out.println(a);
        }*/
        Object o = new Object();
        Object o1 = new Object();
        System.out.println(o.equals(o1));
        // System.out.println(o==o1);
    }

    /**
     * 冒泡排序
     */
    @Test
    public void test02() {
        int arr[] = new int[]{54, 34, 64, 43, 35, 21, 13, -56, 103, 22};
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length - 1 - i; j++) {
                if (arr[j] > arr[j + 1]) {
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
        System.out.println(Arrays.toString(arr));
    }

    @Test
    public void test03() {
        Integer a = 100;
        Integer b = 100;
        System.out.println(a == b ? "1" : "2");
        Integer c = 200;
        Integer d = 200;
        Integer e = d;
        System.out.println(e == d ? "1" : "2");
    }
}
